package ooday03.homework;

public class RefArrayDemo {
    public static void main(String[] args) {
        Dog[] dogs = new Dog[3];
        dogs[0] = new Dog("小狗1号",2,"黑色");
        dogs[1] = new Dog("小狗2号",1,"白色");
        dogs[2] = new Dog("小狗3号",3,"黄色");
        System.out.println(dogs[0].name);
        dogs[1].age=2;
        System.out.println("修改后的"+dogs[1].name+"的年龄："+dogs[1].age);
        for (int i = 0;i< dogs.length;i++){
            System.out.println(dogs[i].name+"今年"+dogs[i].age+"岁了，颜色是"+dogs[i].color);
            dogs[i].eat();
            dogs[i].drink();
            dogs[i].swim();
            dogs[i].lookHome();
        }

        System.out.println("-------------------------");

        Chick[] chicks = new Chick[3];
        chicks[0] = new Chick("小鸡1号",1,"黄色");
        chicks[1] = new Chick("小鸡2号",2,"白色");
        chicks[2] = new Chick("小鸡3号",3,"蓝色");
        chicks[1].age=5;
        System.out.println("修改后的"+chicks[1].name+"的年龄："+chicks[1].age);
        for (int i = 0;i< dogs.length;i++){
            System.out.println(chicks[i].name+"今年"+chicks[i].age+"岁了，颜色是"+chicks[i].color);
            chicks[i].eat();
            chicks[i].drink();
            chicks[i].layEggs();
        }

        System.out.println("-------------------------");

        Fish[] fish = new Fish[2];
        fish[0] = new Fish("小鱼1号",2,"红色");
        fish[1] = new Fish("小鱼2号",1,"绿色");
        fish[1].age=2;
        System.out.println("修改后的"+fish[1].name+"的年龄："+fish[1].age);
        for (int i = 0;i< fish.length;i++){
            System.out.println(fish[i].name+"今年"+fish[i].age+"岁了，颜色是"+fish[i].color);
            fish[i].eat();
            fish[i].drink();
            fish[i].swim();
        }
    }
}
